<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const p1 =new Promise((reslove,reject)=>{
            setTimeout(()=>{
                console.log('第一个请求');
                reslove()
            },2000)
        })

        const p2=new Promise((reslove,reject)=>{
            setTimeout(()=>{
                console.log("第二个请求");
                reslove()
            },3000)
        })

       console.log(p1);
       console.log(p2);

       Promise.all([p1,p2])
       .then(()=>{
           console.log("两个请求已经成功");
       })
       .catch(()=>{
           console.log('失败了');
       })

       //用 async await改造
       ;(async()=>{
           await Promise.all([p1,p2])
           console.log('两个请求都成功了...');
       })()
    </script>
</body>
</html>